home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / ctlib100.zip / INSTALL.LZH / TSTSCRPT.PAS < prev    next >
Pascal/Delphi Source File  |  1996-10-12  |  10KB  |  251 lines

  1. {**************************************************************************}
  2. {*  BitSoft Development, L.L.C.                                           *}
  3. {*  Copyright (C) 1995, 1996 BitSoft Development, L.L.C.                  *}
  4. {*  All rights reserved.                                                  *}
  5. {**************************************************************************}
  6.  
  7. unit TstScrpt;
  8.  
  9. {$X+}
  10.  
  11. interface
  12.  
  13. uses Containr, ctArrays, ctQueues, ctStacks, ctTrees, ctBiTree;
  14.  
  15. procedure TestSequence (Sequence : PSequence; DynamicSequence,
  16.   SortedSequence : Boolean);
  17. { Script used to test base TContainer and TSequence methods. }
  18.  
  19. procedure TestGraph (Graph : PGraph);
  20. { Script used to test base TContainer and TGraph methods. }
  21.  
  22. procedure TestArray (DemoArray : PDynamicArray);
  23. procedure TestResizableArray (DemoArray : PDynamicArray);
  24. procedure TestSortedArray (DemoArray : PDynamicArray);
  25. procedure TestQueue (Queue : PQueue);
  26. procedure TestDoubleEndedQueue (Queue : PDoubleEndedQueue);
  27. procedure TestLinkedStack (Stack : PLinkedStack);
  28. procedure TestStreamStack (Stack : PStreamStack);
  29. procedure TestBinaryTree (Tree : PBinaryTree);
  30. procedure TestHugeCollectionStack (Stack : PHugeCollectionStack);
  31. procedure TestArrayStack(Stack : PArrayStack);
  32. procedure TestHugeArrayStack(Stack : PHugeArrayStack);
  33.  
  34. implementation
  35.  
  36. uses BsdTypes,
  37.      MtdTests, Types, Utils;
  38.  
  39. {****************************************************************************}
  40. { TestArray                                                                  }
  41. {****************************************************************************}
  42. procedure TestArray (DemoArray : PDynamicArray);
  43. begin
  44.   TestSequence(DemoArray, Static, UnSorted);
  45.   TestArrayAtClear(DemoArray);
  46. end;
  47.  
  48. {****************************************************************************}
  49. { TestArrayStack                                                             }
  50. {****************************************************************************}
  51. procedure TestArrayStack (Stack : PArrayStack);
  52. begin
  53.   TestArrayStackPush(Stack);
  54.   TestArrayStackTop(Stack);
  55.   TestArrayStackBottom(Stack);
  56.   TestArrayStackPop(Stack);
  57. end;
  58.  
  59. {****************************************************************************}
  60. { TestDoubleEndedQueue                                                       }
  61. {****************************************************************************}
  62. procedure TestDoubleEndedQueue (Queue : PDoubleEndedQueue);
  63. begin
  64.   TestQueueEnQueue(Queue);
  65.   TestQueueFront(Queue);
  66.   TestQueueRear(Queue);
  67.   TestDoubleEndedQueueRemoveFirst(Queue);
  68.   TestDoubleEndedQueueRemoveLast(Queue);
  69.   TestQueueRemove(Queue);
  70. end;
  71.  
  72. {****************************************************************************}
  73. { TestGraph                                                                  }
  74. {****************************************************************************}
  75. procedure TestGraph (Graph : PGraph);
  76. var
  77.   DuplicateKey : String5;
  78.   DeleteKey, FreeKey, ReplaceKey : String5;
  79. begin
  80.   { TContainer methods }
  81.   TestContainerInsert (Graph, TotalItems);
  82.   TestContainerForEach (Graph);
  83.   TestContainerForEachThat (Graph);
  84.   TestGraphDelete (Graph);
  85.   TestGraphFree (Graph);
  86.   TestContainerDeleteAllThat (Graph);
  87.   TestContainerFreeAllThat (Graph);
  88.   TestContainerPack (Graph);
  89.   TestContainerFreeAll (Graph);
  90.   TestContainerInsert (Graph, TotalDeleteItems);
  91.   TestGraphDeleteAll (Graph);
  92.   if not ExitTesting
  93.     then Graph^.Pack;
  94.   TestContainerInsert (Graph, TotalItems);
  95.  
  96.   { TGraph methods }
  97.   TestGraphFirst (Graph);
  98.   TestGraphLast (Graph);
  99.   TestGraphNext (Graph);
  100.   TestGraphPrev (Graph);
  101.   TestGraphFirstThat (Graph, DuplicateKey);
  102.   TestGraphLastThat (Graph, DeleteKey);
  103.   TestGraphNextThat (Graph, FreeKey);
  104.   TestGraphPrevThat (Graph, ReplaceKey);
  105.   TestGraphDuplicates (Graph, DuplicateKey);
  106.   TestGraphKeyFirst (Graph, DuplicateKey);
  107.   TestGraphNextExactMatch (Graph, DuplicateKey);
  108.   TestGraphPrevExactMatch (Graph, DuplicateKey);
  109.   TestGraphKeyLast (Graph, DuplicateKey);
  110.   TestGraphKeyFirstThat(Graph, DuplicateKey);
  111.   TestGraphKeyLastThat(Graph, DuplicateKey);
  112.   TestGraphItemPut (Graph, ReplaceKey);
  113.   TestGraphItemReplace (Graph, FreeKey);
  114.   TestGraphFind (Graph, DuplicateKey);
  115.   TestGraphFindThat (Graph, DuplicateKey);
  116. end;
  117.  
  118. {****************************************************************************}
  119. { TestHugeArrayStack                                                         }
  120. {****************************************************************************}
  121. procedure TestHugeArrayStack (Stack : PHugeArrayStack);
  122. begin
  123.   TestHugeArrayStackPush(Stack);
  124.   TestHugeArrayStackTop(Stack);
  125.   TestHugeArrayStackBottom(Stack);
  126.   TestHugeArrayStackPop(Stack);
  127. end;
  128.  
  129. {****************************************************************************}
  130. { TestHugeCollectionStack                                                    }
  131. {****************************************************************************}
  132. procedure TestHugeCollectionStack (Stack : PHugeCollectionStack);
  133. begin
  134.   TestHugeCollectionStackPush(Stack);
  135.   TestHugeCollectionStackTop(Stack);
  136.   TestHugeCollectionStackBottom(Stack);
  137.   TestHugeCollectionStackPop(Stack);
  138. end;
  139.  
  140. {****************************************************************************}
  141. { TestLinkedStack                                                            }
  142. {****************************************************************************}
  143. procedure TestLinkedStack (Stack : PLinkedStack);
  144. begin
  145.   TestLinkedStackPush(Stack);
  146.   TestLinkedStackTop(Stack);
  147.   TestLinkedStackBottom(Stack);
  148.   TestLinkedStackPop(Stack);
  149. end;
  150.  
  151. {****************************************************************************}
  152. { TestQueue                                                                  }
  153. {****************************************************************************}
  154. procedure TestQueue (Queue : PQueue);
  155. begin
  156.   TestQueueEnQueue(Queue);
  157.   TestQueueFront(Queue);
  158.   TestQueueRear(Queue);
  159.   TestQueueRemove(Queue);
  160. end;
  161.  
  162. {****************************************************************************}
  163. { TestResizableArray                                                         }
  164. {****************************************************************************}
  165. procedure TestResizableArray (DemoArray : PDynamicArray);
  166. begin
  167.   TestSequence(DemoArray, Dynamic, Unsorted);
  168.   TestArrayAtClear(DemoArray);
  169. end;
  170.  
  171. {****************************************************************************}
  172. { TestSortedArray                                                            }
  173. {****************************************************************************}
  174. procedure TestSortedArray (DemoArray : PDynamicArray);
  175. begin
  176.   TestSequence(DemoArray, Dynamic, Sorted);
  177.   TestArrayAtClear(DemoArray);
  178. end;
  179.  
  180. {****************************************************************************}
  181. { TestStreamStack                                                            }
  182. {****************************************************************************}
  183. procedure TestStreamStack (Stack : PStreamStack);
  184. begin
  185.   TestStreamStackPush(Stack);
  186.   TestStreamStackTop(Stack);
  187.   TestStreamStackBottom(Stack);
  188.   TestStreamStackPop(Stack);
  189. end;
  190.  
  191. {****************************************************************************}
  192. { TestSequence                                                               }
  193. {****************************************************************************}
  194. procedure TestSequence (Sequence : PSequence; DynamicSequence,
  195.   SortedSequence : Boolean);
  196. begin
  197.   { TContainer methods }
  198.   if DynamicSequence
  199.     then TestContainerInsert (Sequence, TotalItems)
  200.     else TestStaticSequenceInsert (Sequence, TotalItems);
  201.   TestContainerForEach (Sequence);
  202.   TestContainerForEachThat (Sequence);
  203.   TestSequenceDelete (Sequence);
  204.   TestSequenceFree (Sequence);
  205.   TestContainerDeleteAllThat (Sequence);
  206.   TestContainerFreeAllThat (Sequence);
  207.   TestContainerPack (Sequence);
  208.   TestContainerFreeAll (Sequence);
  209.   if DynamicSequence
  210.     then TestContainerInsert (Sequence, TotalDeleteItems)
  211.     else TestStaticSequenceInsert (Sequence, TotalDeleteItems);
  212.   TestSequenceDeleteAll (Sequence);
  213.   if not ExitTesting
  214.     then Sequence^.Pack;
  215.   if DynamicSequence
  216.     then TestContainerInsert (Sequence, TotalItems)
  217.     else TestStaticSequenceInsert (Sequence, TotalItems);
  218.   { TSequence methods }
  219.   TestSequenceAt (Sequence);
  220.   TestSequenceAtDelete (Sequence);
  221.   TestSequenceAtFree (Sequence);
  222.   if not SortedSequence
  223.     then begin
  224.            if DynamicSequence
  225.              then TestSequenceAtInsert (Sequence)
  226.              else TestStaticSequenceAtInsert (Sequence);
  227.            TestSequenceAtPut (Sequence);
  228.          end; { if }
  229.   TestSequenceFirst (Sequence);
  230.   TestSequenceNext (Sequence);
  231.   TestSequenceLast (Sequence);
  232.   TestSequencePrev (Sequence);
  233.   TestSequenceFirstThat (Sequence);
  234.   TestSequenceNextThat (Sequence);
  235.   TestSequenceLastThat (Sequence);
  236.   TestSequencePrevThat (Sequence);
  237.   if SortedSequence
  238.     then TestSequenceSearch (Sequence);
  239. end;
  240.  
  241. {****************************************************************************}
  242. { TestBinaryTree                                                             }
  243. {****************************************************************************}
  244. procedure TestBinaryTree (Tree : PBinaryTree);
  245. begin
  246.   TestGraph (Tree);
  247.   TestTreeTraverse (Tree);
  248.   TestTreeTraverseThat (Tree);
  249. end;
  250.  
  251. end.